﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="分页.aspx.cs" Inherits="PageDisplay.index" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="fly" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Scripts/pagination/pagination.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/pagination/jquery.min.js" type="text/javascript"></script>
    <script src="Scripts/pagination/jquery.pagination.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        var pageIndex = 0;     //页面索引初始值   
        var pageSize = 3;     //每页显示条数初始化，修改显示条数，修改这里即可
        var totleRecord = 0;

        var firstLoad = true;//解决第一次加载时请求两次的问题

        function callback(index, jq) {
            if (firstLoad) {
                firstLoad = false;
                return;
            }
            GetData(index);
            return false;
        }

        function GetData(index) {
            $.ajax({
                type: "post",
                url: "../Ajax/Test.ashx",
                async:false,
                dataType: "post",
                data: { pageindex: index, pagesize: pageSize },
                success: function (d) {
                    alert(d);
                    totleRecord = 40;
                }
            });
        }

        $(function () {
            GetData(0);
            $("#pager2").pagination(totleRecord,
             {
                 items_per_page: pageSize, // 每页显示多少条记录
                 current_page: 0,  //当前页
                 num_display_entries: 4, // 分页显示的条目数
                 next_text: "下一页",
                 prev_text: "上一页",
                 num_edge_entries: 2, // 连接分页主体，显示的条目数
                 callback: callback
             }

            );

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">

    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField>
                <HeaderTemplate>
                    <asp:CheckBox ID="cbHead" runat="server" Checked="false" OnCheckedChanged="SelectAll" AutoPostBack="true" Text="全选" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="cbItem" runat="server"  Checked="false" Text=""/>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="tempid" HeaderText="临时ID" Visible="False" />
                <asp:BoundField DataField="ID" HeaderText="班级ID" />
                <asp:BoundField DataField="className" HeaderText="班级名称" />
                <asp:BoundField DataField="classDesc" HeaderText="班级描述" />
                <asp:BoundField DataField="isDel" HeaderText="是否删除" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:HiddenField ID="HiddenField1" runat="server" /> 
        <br />
    </div>
    <div>
            <fly:aspnetpager ID="pager" runat="server" PageSize="3" ShowPageIndexBox="Always"
        OnPageChanged="pager_PageChanged" FirstPageText="首页" LastPageText="尾页" 
                NextPageText="后页" PrevPageText="前页">
    </fly:aspnetpager>
    </div>
    &nbsp;
    &nbsp;

    <div id="pager2" class="pagination"></div>
    </form>
    
        
</body>
</html>
